<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .container {
        width: 210px;
        height: 90px;
        background: url('./img/360x260@2x@2x.png') no-repeat;
        background-size: 100% 100%;
        padding: 2px 5px;
      }
      .header {
        height: 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .title {
        color: #fff;
        margin-left: 25px;
      }
      .close {
        color: #fff;
        z-index: 100;
        cursor: pointer;
        width: 20px;
        height: 20px;
        /* 禁用选中 */
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
      }

      .content {
        color: #fff;
        display: flex;
        height: 20px;
        margin-top: 10px;
        margin-left: 10px;
        font-size: 13px;
      }
      .value {
        margin-left: 10px;
      }
    </style>

    <script src="../ac.min.js"></script>
  </head>
  <body>
    <div class="container" onclick="close1()">
      <div class="header">
        <div class="title" id="Title">直升机详情</div>
        <div class="close">X</div>
      </div>
      <div class="content">
        <div class="key">速度:</div>
        <div class="value" id="speed">33米/秒</div>
      </div>
      <div class="content">
        <div class="key">高度:</div>
        <div class="value" id="height">1052米</div>
      </div>
    </div>
    <script>
      let curZhiShenJiHeight = '356.9米'
      let curZhiShenJiSpeed = '55.1米/秒'
      let zhiShenJiHeigt = [
        '356.9米',
        '369.4米',
        '358.1米',
        '321.4米',
        '347.3米',
        '314.8米',
        '309.4米',
        '347.2米',
        '337.1米',
        '315.9米'
      ]
      let zhiShenJiSpeed = [
        '55.1米/秒',
        '55.6米/秒',
        '55.8米/秒',
        '54.2米/秒',
        '56.9米/秒',
        '54.7米/秒',
        '55.9米/秒',
        '56.0米/秒',
        '57.6米/秒',
        '56.5米/秒'
      ]

      let curEvtolHeight = '51.63米'
      let curEvtolSpeed = '14.1米/秒'
      let evtolHeigt = [
        '51.63米',
        '50.98米',
        '56.15米',
        '52.67米',
        '53.16米',
        '51.05米',
        '54.29米',
        '54.36米',
        '56.17米',
        '54.28米'
      ]
      let evtolSpeed = [
        '14.1米/秒',
        '15.6米/秒',
        '16.8米/秒',
        '14.2米/秒',
        '15.9米/秒',
        '16.7米/秒',
        '14.9米/秒',
        '15.0米/秒',
        '16.6米/秒',
        '14.5米/秒'
      ]

      let xunjianSpeed = [
        '8.1米/秒',
        '8.6米/秒',
        '7.8米/秒',
        '6.2米/秒',
        '8.9米/秒',
        '7.7米/秒',
        '8.9米/秒',
        '7.0米/秒',
        '9.6米/秒',
        '8.5米/秒'
      ]

      function random(m, n) {
        return Number(m + Math.random() * (n - m)).toFixed(1)
      }
      function getParams(param) {
        const parmas = new URLSearchParams(window.location.search)
        return parmas.get(param)
      }

      const chanshuStr = getParams('parmas')
      const chanshu = JSON.parse(chanshuStr)
      document.getElementById('Title').innerHTML = chanshu.name + '详情'
      if (chanshu.name.includes('滑翔伞')) {
        document.getElementById('speed').innerHTML = '10米/秒'
        document.getElementById('height').innerHTML = '552米'
        // document.getElementById('speed').innerHTML = `${random(10, 20)}m/s}`
        // document.getElementById('height').innerHTML = `${random(100, 300)}m}`
      } else if (chanshu.name.includes('evtol')) {
        setInterval(() => {
          // 生成一个随机索引，范围是0到数组长度减1
          const randomIndex = Math.floor(Math.random() * evtolHeigt.length)
          const randomIndex1 = Math.floor(Math.random() * evtolSpeed.length)
          // 根据随机索引获取数组中的元素
          curEvtolHeight = evtolHeigt[randomIndex]
          curEvtolSpeed = evtolSpeed[randomIndex1]
          document.getElementById('speed').innerText = `${random(6, 10)}米/秒`
          document.getElementById('height').innerText = `${random(50, 70)}米`
        }, 1000)
      } else if (chanshu.name.includes('亿航')) {
        // document.getElementById('speed').innerHTML = '20米/秒'
        // document.getElementById('height').innerHTML = '300米'
        setInterval(() => {
          // 生成一个随机索引，范围是0到数组长度减1
          const randomIndex = Math.floor(Math.random() * evtolHeigt.length)
          const randomIndex1 = Math.floor(Math.random() * evtolSpeed.length)
          // 根据随机索引获取数组中的元素
          curEvtolHeight = evtolHeigt[randomIndex]
          curEvtolSpeed = evtolSpeed[randomIndex1]
          // document.getElementById('speed').innerHTML = curEvtolSpeed
          // document.getElementById('height').innerHTML = curEvtolHeight
          document.getElementById('speed').innerHTML = `${random(6, 10)}米/秒`
          document.getElementById('height').innerHTML = `${random(50, 70)}米`
        }, 1000)
      } else if (chanshu.name === '飞行态势') {
        document.getElementById('Title').innerHTML = chanshu.name
        document.getElementById('speed').innerHTML = '20米/秒'
        document.getElementById('height').innerHTML = '300米'
      } else if (chanshu.name.indexOf('物流无人机') > -1) {
        // 直升机的气泡改
        setInterval(() => {
          // 生成一个随机索引，范围是0到数组长度减1
          const randomIndex = Math.floor(Math.random() * zhiShenJiHeigt.length)
          const randomIndex1 = Math.floor(Math.random() * zhiShenJiSpeed.length)
          // 根据随机索引获取数组中的元素
          curZhishengjiHeight = zhiShenJiHeigt[randomIndex]
          curZhishengjiSpeed = evtolSpeed[randomIndex1]
          // document.getElementById('speed').innerHTML = curZhishengjiSpeed
          // document.getElementById('height').innerHTML = curZhishengjiHeight

          document.getElementById('speed').innerHTML = `${random(6, 10)}米/秒`
          document.getElementById('height').innerHTML = `${random(50, 70)}米`
        }, 1000)
      } else if (chanshu.name.indexOf('巡检无人机') > -1) {
        // 直升机的气泡改
        setInterval(() => {
          // 生成一个随机索引，范围是0到数组长度减1
          const randomIndex = Math.floor(Math.random() * zhiShenJiHeigt.length)
          const randomIndex1 = Math.floor(Math.random() * zhiShenJiSpeed.length)
          // 根据随机索引获取数组中的元素
          curZhishengjiHeight = zhiShenJiHeigt[randomIndex]
          curZhishengjiSpeed = xunjianSpeed[randomIndex1]
          // document.getElementById('speed').innerHTML = curZhishengjiSpeed
          // document.getElementById('height').innerHTML = curZhishengjiHeight
          document.getElementById('speed').innerHTML = `${random(30, 40)}米/秒`
          document.getElementById('height').innerHTML = `${random(300, 600)}米`
        }, 1000)
      } else {
        // 直升机的气泡改
        setInterval(() => {
          // 生成一个随机索引，范围是0到数组长度减1
          const randomIndex = Math.floor(Math.random() * zhiShenJiHeigt.length)
          const randomIndex1 = Math.floor(Math.random() * zhiShenJiSpeed.length)
          // 根据随机索引获取数组中的元素
          curZhishengjiHeight = zhiShenJiHeigt[randomIndex]
          curZhishengjiSpeed = zhiShenJiSpeed[randomIndex1]

          document.getElementById('speed').innerHTML = `${random(30, 40)}米/秒`
          document.getElementById('height').innerHTML = `${random(300, 600)}米`
        }, 1000)
      }

      function close1() {
        let __g = new DigitalTwinPlayer()
        ue.internal.postevent('close&' + chanshu.id)
      }
    </script>
  </body>
</html>
